<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link href="public/css.css" rel="stylesheet" type="text/css" />
        <title>Thiện Wroks</title>
    </head>

    <body>
        <?php
        require_once 'model2/wonks2.php';

        $keyword = new Works();
        $keyword->table_name = "works";
        ?>
        <?php
        if (!isset($_GET["page"]))
            $page = 1;
        else
            $page = $_GET["page"];
            $keywords = $keyword->select($page);
            $total = $keyword->countWords();
        ?>
        <div class="chung">
            <div class="hinh"></div>
            <h2>Wroks TDC</h2>
            <div class="menu">
                <ul>
                    <li><a href="#"> Menu</a></li>
                    <li><a href="#"> Content types</a></li>
                    <li><a href="#"> Forums</a></li>
                    <li><a href="#"> Contact</a></li>
                    <li> <input type="text" id="type"/><input type="button" value="go" id="ty"></li>
                </ul>
                <div class="thanh"></div>
                
            </div>
            <div class="noidung">
                <hr id="like"></hr>
                <div class="nav" style="clear: both;">
                <ul>
                    <li><a href="index2.php?page=1">Fist </a></li>
                    <li><a href="index2.php?page=<?php echo $page - 1 ?>"> << Prev </a></li>
                    <?php for ($i = 1; $i <= $total / PAGE; $i++): ?>
                        <li>
                            <a href="index2.php?page=<?php echo $i ?>">
                                <?php echo $i ?>
                            </a>
                        </li>
                        <?php endfor; ?>
                        <li><a href="index2.php?page=<?php echo $page + 1  ?>">Next >> </a></li>
                        <li><a href="index2.php?page=<?php echo $total / PAGE ?>">Last </a></li>
                    </ul>
                </div>
                <table border="1px" style="clear: both;" class="nd">
                    <tr  id="tr" >
                        <td>Id</td>
                        <td>Name</td>
                        <td>Description</td>
                    </tr>
                    <?php foreach ($keywords as $keywords_n): ?>
                        <tr>
                            <td> <?php echo $keywords_n["id"]; ?></td>
                            <td><?php echo $keywords_n["name"]; ?></td>
                            <td><?php echo substr($keywords_n['description'], 0, 100); ?></td>
                        </tr>
                    <?php endforeach; ?>

                </table>
            </div>
            <div class="nav">
                <ul>
                    <li><a href="index.php?page=1"> Fist </a></li>
                    <?php for ($i = 1; $i <= $total / PAGE; $i++): ?>
                        <li>
                            <a href="index.php?page=<?php echo $i ?>">
                                <?php echo $i ?>
                            </a>
                        </li>
                        <?php endfor; ?>
                        <li><a href="index.php?page=<?php echo $total / PAGE ?>">Last </a></li>
                    </ul>
                </div>           
        </div>
    </body>
</html>
